import React, { useEffect,useState } from 'react';
import StudentList from './component/StudentList';
const STU_DATA = [
{
    id:'1',
    attributes:{
        name:'悟空',
        age:18,
        gender:'男',
        address:'花果山'
    }
},
{
    id:'2',
    attributes:{
        name:'悟能',
        age:19,
        gender:'男',
        address:'高老庄'
    }
},
{
    id:'3',
    attributes:{
        name:'悟净',
        age:20,
        gender:'男',
        address:'流沙河'
    }
}
]
const App = (props) => {    
    const [stuData, setStuData] = useState(STU_DATA);
    //没服务器玩，写不了了
    useEffect(()=>{
        fetch('http://localhost:1337/api/students').then((response)=>{
            console.log(response)
          return  response.json();
        }).then((data)=>{
            console.log(data)
        }).catch((error)=>{
            console.log(error.message)
        })
    },[])
return(
    <div className='app'>
        <StudentList stus={stuData}></StudentList>
    </div>
    )
};
export default App